<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="../res/css/weui.css"/>
<link rel="stylesheet" href="../res/css/weuix.css"/>
<link rel="stylesheet" href="../res/css/common.css" />
<script src="../res/js/zepto.min.js"></script>
<script src="../res/js/zepto.weui.js"></script>
<script src="../res/js/common.js?v=1"></script>
<script>
	var log_id='',nPageIndex='';
    //获取问诊详情
    function getInquiryLogDetails(log_id) {
        var paramJson = {
            "id": log_id
        };
		newAjaxPost("/h5/inquiryLog/getAllInfo", paramJson, getInquiryLogDetailsOk);
        return false;
    }

    function getInquiryLogDetailsOk(jsonInfo) {
        if (jsonInfo.code == '1') {
            var data = jsonInfo.data;
            var guidanceList = data.inquiryLogHealthGuidanceList; 		//健康指导列表
            var hospitalizationList = data.hospitalizationDetailResp; 	//住院建议
            var formList = data.formListResult; 						//申请单列表
            var prescriptionList = data.prescriptionList;				//处方列表
            var checklistList = data.inspectionOpinionList;				//检验单列表
			if(data.acceptsTime==null){
				$(".record_id").text('无问诊编号');
				$(".lrsj").text('无就诊时间'); //就诊时间
			}else{
				$(".record_id").text(nothinglrsj(data.acceptsTime)+ data.id);
				$(".lrsj").text(data.acceptsTime); //就诊时间
			}
            $(".patient_name").text(data.patientName); //姓名
            $(".patient_sex").text(data.patientSex == 1 ? "女" : "男"); //性别
            // $(".pay_type").text(data.paymentMethod == 1 ? "医保缴费" : data.pay_type == 0 ? "自费缴费" : "未提供"); //性别
            $(".pay_type").text("自费缴费"); //性别
            $(".patientAge").text(data.patientAge + '岁'); //年龄
            $(".inquiry_patient_phone").text(data.patientPhone); //手机号
            var is_married = data.isMarried == 0 ? "未婚" : "已婚";
            $(".is_married").text(is_married); 
            if (isUndefinedAndEmpty(data.patientWeight)) {
                var inquiry_patient_weight = '未提供'; 
            } else {
                var inquiry_patient_weight = data.patientWeight + 'kg'; 
            }
            $(".patient_marital_status").text(nothingFun(data.patientMaritalStatus, '未提供')); //籍贯
            $(".patient_weight").text(inquiry_patient_weight); //体重
            
            $(".doctor_name").text(data.doctorName); //就诊医生
            $(".department_name").text(data.departmentName); //医疗科室
            $(".doctor_work_address").text(data.doctor_work_address); //医疗机构
            $(".inquiry_patient_profession").text(nothingFun(data.patientProfession, '未提供')); //职业
            $(".inquiry_patient_address").text(nothingFun(data.patientAddress, '未提供')); //住址
            if (data.isDrugAllergy == 0) {
                $(".iinquiry_patient_allergy_details").text('无'); //过敏史
                // data.patientAllergyDetails = '';
            } else {
                $(".iinquiry_patient_allergy_details").text(nothingFun(data.patientAllergyDetails, '是，未提供')); //过敏史
            }
            $(".log_main_suit").text(nothingFun(data.mainSuit, '无')); //主诉
            $(".log_present_illness").text(nothingFun(data.presentIllness, '无')); //现病史
            $(".log_history_present_illness").text(nothingFun(data.historyPresentIllness, '无')); //既往史
            if(data.diagnosisArray){
            	var diagnosislist='';
            	for(var i=0;i<data.diagnosisArray.length;i++){
            		if(i!=0){diagnosislist+='、'}
            		diagnosislist+=data.diagnosisArray[i].diagnosis;
            	}
            	$(".lof_diagnosis").text(diagnosislist); //诊断
            }else{
            	$(".lof_diagnosis").text('无'); //诊断
            }
            // $(".lof_diagnosis").text(nothingFun(data.diagnosis, '无')); //诊断
        
            //1.处方列表
            prescriptionListC = '';
            if (prescriptionList&&prescriptionList.length > 0) {
                $.each(prescriptionList, function (e, item) {
                    if (item.prescriptionType == 1) {
                        item.prescriptionType = "(中)"
                        var prescriptiontype = '中药处方'
                    }
                    if (item.prescriptionType == 2) {
                        item.prescriptionType = "(西)"
                        var prescriptiontype = '西药处方'
                    }
            		prescriptionListC += '<button onclick="showChatPage(&quot;1&quot;,&quot;' + item.id + '&quot;)">'+prescriptiontype+' No：' + item.prescriptionNo + '</button>';
                })
            
            
            } else {
                prescriptionListC = '暂无处方列表';
            }
            $(".prescriptionListC").html(prescriptionListC);
            
            //2.检验检查
            checklistListC = '';
            var prescription_guidance = '';
            if (checklistList&&checklistList.length > 0) {
                $.each(checklistList, function (e, item) {
                    checklistListC += '<button onclick="showChatPage(&quot;2&quot;,&quot;' + item.id + '&quot;)">检验检查 No：' + item.applicationFormNo + '</button>';
                })
            }
            else
                checklistListC = '暂无检验检查';
            $(".checklistListC").html(checklistListC)
			
            //健康指导
            guidanceListC = '';
            if (guidanceList&&guidanceList.length > 0) {
                $.each(guidanceList, function (e, item) {
                    guidanceListC += '<button onclick="showChatPage(&quot;3&quot;,&quot;' + item.id + '&quot;)">健康指导 No：' + item.healthGuidanceNo + '</button>';
                })
            }
            else
                guidanceListC = "暂无检验检查";
            $(".guidanceListC").html(guidanceListC);
			
            //住院建议
            var hospitalizationListC = '';
            if (hospitalizationList!=null) {
                // $.each(hospitalizationList, function (e, item) {
                    hospitalizationListC += '<button onclick="showChatPage(&quot;4&quot;,&quot;' + log_id + '&quot;)">住院建议 No：' + log_id + '</button>';
                // })
            }
            else
                hospitalizationListC = "暂无住院建议";
            $(".hospitalizationListC").html(hospitalizationListC);
            
            //申请单
            var formListResultC = '';
            if (formList&&formList.length > 0) {
                $.each(formList, function (e, item) {
                    formListResultC += '<button onclick="showChatPage(&quot;5&quot;,&quot;' + item.id + '&quot;,&quot;' + item.templateValue + '&quot;)">申请单 No：' + item.applicationFormNo + '</button>';
                })
            }
            else
                formListResultC = "暂无申请单";
            $(".formListResultC").html(formListResultC);
        }
        else
            msgInfo(jsonInfo.info);
    }

    //显示数据
    function showChatPage(pageIndex, pageId, template) {
        var paramJson, strDoName;
        nPageIndex = pageIndex;
        paramJson={
        	'id':pageId,
        	"type": 2
        }
        switch (nPageIndex) {
            case "1": //处方
                paramJson.resourceType = 4;
                // prescription_id = pageId;
                // $('#btnBuyOrder').show();
                break;
            case "2": //检验检查
                paramJson.resourceType = 3;
                break;
            case "3": //健康指导
                paramJson.resourceType = 2;
                break;
            case "4": //住院建议
                paramJson.resourceType = 1;
                break;
        	case "5": //申请单
        	    paramJson.resourceType = 5;
        		paramJson.template = template;
        	    break;
        }
        newAjaxPost('/h5/pdf/getEstablishPdf', paramJson, showChatPageOk);
        return false;
    }

    function showChatPageOk(jsonInfo) {
        if (jsonInfo.code == '1') {
            var imgUrl, pageTitle;
            var data = jsonInfo.data;
            switch (nPageIndex) {
                case "1": //处方详情
                    imgUrl = data.url;
                    pageTitle = "处方详情";
                    break;
                case "2": //检验检查
                    imgUrl = data.url;
                    pageTitle = "检验检查";
                    break;
                case "3": //健康指导
                    imgUrl = data.url;
                    pageTitle = "健康指导";
                    break;
                case "4": //住院建议
                    imgUrl = data.url;
                    pageTitle = "住院建议";
                    break;
				case "5": //申请单
					imgUrl = data.url;
					break;
            }
            $('.title').html(pageTitle);
            $('.imgShow').attr("src", imgUrl);
            $("#divRecordImg").popup(); //打开
        }
        else
            msgInfo(jsonInfo.info);
    }

    function nothinglrsj(str) {
        var str_Y = str.substring(0, 4);
        var str_M = str.substring(5, 7);
        var str_D = str.substring(8, 10);
        return str_Y + str_M + str_D;
    }

    function nothingFun(str, txt) {
        if (isUndefinedAndEmpty(str)) {
            return txt
        } else {
            return str
        }
    }

    $(function () {
		log_id = getQst("log_id")
        getInquiryLogDetails(getQst("log_id"));
		
		//返回上页
		$('#btnBack').on("click", function () {
		    history.go(-1);
		});
    });


</script>
<style>
.header {text-align:center;z-index:1;width:100%;top:0;transition:0.5s;}
.doctor-avatar {width:100px;height:100px;border:1px solid #006400;border-radius:50%;display:block;margin: 0 auto 0.2933rem;}
.img-wrapper {box-sizing: border-box;float: left;display: inline-block;display: inline-flex;align-items: center;width: 4rem;height: 4rem;overflow: hidden;margin: 0.2rem 0.25rem;}
.img-wrapper>img {border-radius: 50%;}
img {width:100%;height: 100%;}
.fixed-top{border-bottom:1px solid #e8e8e8;position:fixed;left:0;top:0;right:0;z-index:1;background:#F6F6F9}
.font14{ font-size:14px; line-height:20px}
.mright15{ margin-right:15px}
button{border-radius:5px;  height: 30px;  width: 224px;  background-color: #1189ff;  color: #ffffff; outline: none; border: 1px solid;}

.green_btn{background: #1189ff; border-radius: 3px; padding: 0 3px; color: white;}
.record_body>div{margin-bottom: 10px; background: white; border-radius:10px ;}
.show{
	display: flex;
	    background: #ffffff;
	    height: 44px;
}
.show .weui-cell__bd{
	align-self: center;
	    font-size: 16px;
	    margin-left: 20px;
}
.show .weui-cell__ft{
	align-self: center;
	    margin-right: 5px;
	    border: 1px #1189ff solid;
	    border-radius: 10px;
		overflow: hidden;
}
.weui-btn:after { content: none;}
.weui-popup__modal {background-color: #F9F8FE;}
</style>
<body ontouchstart >
    <div class="fixed-top">
    <div class="weui-header weui-btn_primary"> 
        <div class="weui-header-left"><a id="btnBack" class="icon icon-109"></a></div>
        <div class="weui-header-title">病历中心</div>
        <div class="weui-header-right"></div>
    </div>
    </div>
    <div style="z-index:-1;margin-top: 45px;">
        <div class="weui-cells weui-cells_form record_body" style="overflow:auto" >
            <div class="weui-cell">
                <div class="weui-cell__bd font14">
                    编号：<span class="record_id"></span>
                </div>
                <div class="weui-cell__ft">&nbsp;</div>
            </div>
            <div class="weui-cell weui-flex">
                <div class="weui-flex__item"><div class="font14" style="width:140px">姓名：<span class="patient_name"></span></div></div>
                <div class="weui-flex__item"><div class="font14">性别：<span class="patient_sex"></span></div></div>
                <div class="weui-flex__item"><div class="font14">年龄：<span class="patientAge"></div></div>
            </div>
            <div class="weui-cell weui-flex">
                <div class="weui-flex__item"><div class="font14" style="width:140px">电话：<span class="inquiry_patient_phone"></span></div></div>
                <div class="weui-flex__item"><div class="font14">婚姻：<span class="is_married"></span></div></div>
                <div class="weui-flex__item"><div class="font14">籍贯：<span class="patient_marital_status"></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14" style="width:140px">体重：<span class="patient_weight"></span></div></div>
                <div class="weui-cell__hd"><div class="font14">职业：<span class="inquiry_patient_profession"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">住址：<span class="inquiry_patient_address"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">药物过敏史：<span class="iinquiry_patient_allergy_details"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">主诉：<span class="log_main_suit"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">现病史：<span class="log_present_illness"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">既往史：<span class="log_history_present_illness"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">诊断：<span class="lof_diagnosis"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">就诊日期：<span class="lrsj"></span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">电子处方<span style="color: red; font-size: 13px;">（点击下方按钮查看处方详情）</span><br/><span class="prescriptionListC">暂无数据</span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">检验检查<span style="color: red; font-size: 13px;">（点击下方按钮查看检查详情）</span><br/><span class="checklistListC">暂无数据</span></div></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">健康指导<span style="color: red; font-size: 13px;">（点击下方按钮查看指导详情）</span><br/><span class="guidanceListC">暂无数据</span></div></div>
            </div>
			<div class="weui-cell">
			    <div class="weui-cell__hd"><div class="font14">申请单<span style="color: red; font-size: 13px;">（点击下方按钮查看申请单）</span><br/><span class="formListResultC">暂无数据</span></div></div>
			</div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><div class="font14">住院建议<span style="color: red; font-size: 13px;">（点击下方按钮查看建议详情）</span><br/><span class="hospitalizationListC">暂无数据</span></div></div>
            </div>
        </div>
    </div>
<!--病历详情-->
<div id="divRecordImg" class='weui-popup__container'>
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="weui-cells weui-cells_form" style="width:100%;height:100%;overflow:auto">
            <div class="show">
                <div class="weui-cell__bd font14">
                    <span class="title"></span>
                </div>
                <div class="weui-cell__ft"><a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary close-popup">关闭</a></div>
            </div>
            
                <img style="width:100%;height: 85%;" class="imgShow" />
            
        </div>
    </div>
</div>
</body>
</html>